using System;using System.IO;using System.Windows;using System.Windows.Controls;namespace WPFVLC{ /// <summary> /// VLCCtl.xaml 的交互逻辑 /// </summary> public partial class VLCCtl : UserControl { public VLCCtl() { InitializeComponent(); } private void UserControl_Loaded(object sender, RoutedEventArgs e) { Load(); } private void Load() { if (IntPtr.Size == 4) { // Use 32 bits library this.VLCPlayer.MediaPlayer.VlcLibDirectory = new DirectoryInfo(System.IO.Path.Combine(Environment.CurrentDirectory, "libvlc_x86")); } else { // Use 64 bits library this.VLCPlayer.MediaPlayer.VlcLibDirectory = new DirectoryInfo(System.IO.Path.Combine(Environment.CurrentDirectory, "libvlc_x64")); } var options = new string[] { // VLC options can be given here. Please refer to the VLC command line documentation. }; this.VLCPlayer.MediaPlayer.VlcMediaplayerOptions = options; // Load libvlc libraries and initializes stuff. It is important that the options (if you want to pass any) and lib directory are given before calling this method. this.VLCPlayer.MediaPlayer.EndInit(); } public void Stop() { this.VLCPlayer.MediaPlayer.Stop(); } public void Play(string uri) { this.VLCPlayer.MediaPlayer.Play(uri); } }}
评论